﻿

Dcqtech_Form_Controls.RadioBox = $.extend({}, Dcqtech_Form_Controls.Default);

Dcqtech_Form_Controls.RadioBox.setValue = function (id,value, wdInfo,$root) {
    $root.find("[dcqtech_data='" + id + "']").val(value);
    $root.find("[dcqtech_id='" + id + "'] input[type='radio'][value='" + value + "']").prop("checked", true);
}

Dcqtech_Form_Controls.RadioBox.setDefaultValue = function (id, $root, wdInfo) {
    var value = wdInfo.defaultValue;
    if (!value) return;
    value = template.render(value,ServerParam);
    Dcqtech_Form_Controls.RadioBox.setValue(id, value, wdInfo, $root);
    $("[dcqtech_id='" + id + "']").css("height","44px");
    $("[dcqtech_id='" + id + "']").css("line-height","44px");
    $("[dcqtech_id='" + id + "'] input[type='radio']").css("margin-left","10px");
}

Dcqtech_Form_Controls.RadioBox.setReadonly = function (id, isReadOnly) {
    if (typeof isReadOnly != "boolean") {
        isReadOnly = isReadOnly == "1";
    }
    $("[dcqtech_id='" + id + "'] input[type='radio']").prop("disabled", isReadOnly);
};

Dcqtech_Form_Controls.RadioBox.setEditEvent = function (id, wdInfo, $root) {
    var $control = $root.find("[dcqtech_id='" + id + "'] ");
    if ($control.attr("dcq_inited") == "1") return;
    $control.attr("dcq_inited", "1");
    $control.on("click", "input[type='radio']", function () {
        console.info(this);
        $root.find("[dcqtech_data='" + id + "']").val(this.value);
    });
};